//////////////////////////////////////////////////////////////////////////////////
//                                                                              //
//  This file is part of the buola project (https://code.google.com/p/buola/).  //
//                                                                              //
//  Copyright(c) 2007-2012 Xavi Gratal                                          //
//  gratal AT gmail DOT com                                                     //
//                                                                              //
//  Buola is free software: you can redistribute it and/or modify               //
//  it under the terms of the GNU General Public License as published by        //
//  the Free Software Foundation, either version 3 of the License, or           //
//  (at your option) any later version.                                         //
//                                                                              //
//  Buola is distributed in the hope that it will be useful,                    //
//  but WITHOUT ANY WARRANTY; without even the implied warranty of              //
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               //
//  GNU General Public License for more details.                                //
//                                                                              //
//  You should have received a copy of the GNU General Public License           //
//  along with buola.  If not, see <http://www.gnu.org/licenses/>.              //
//                                                                              //
//////////////////////////////////////////////////////////////////////////////////

#include <buola/utility/cunittest.h>
#include <buola/iterator/range.h>
#include <forward_list>
#include <list>

using namespace buola;

int main(int pArgC,char **pArgs)
{
    buola_init(pArgC,pArgs);
    
    CUnitTest lTest;

    const char *a="aaa";
    std::vector<int> b{1,2,3,4,5};
    int c[]={1,2,3};
    char d[7]="aa";
    wchar_t e[]=L"";
    std::forward_list<int> f{1,2,3,4};
    std::list<int> g{1,3,4};

    lTest.Test(range_size(a)==3,"range_size(const char*)");
    lTest.Test(range_size(b)==5,"range_size(std::vector)");
    lTest.Test(range_size(c)==3,"range_size(int[])");
    lTest.Test(range_size(d)==2,"range_size(char[])");
    lTest.Test(range_size(array_range(d))==7,"range_size(array_range(char[]))");
    lTest.Test(range_size(e)==0,"range_size(wchar_t[])");
    lTest.Test(range_empty(e)==true,"range_empty(wchar_t[])");
    lTest.Test(range_empty(array_range(e))==false,"range_empty(array_range(wchar_t[]))");
    lTest.Test(range_size(f)==4,"range_size(std::forward_list)");
    lTest.Test(range_empty(f)==false,"range_empty(std::forward_list)");
    lTest.Test(range_size(range(g))==3,"range_size(range(std::list))");
    lTest.Test(range_size(g)==3,"range_size(std::list)");
    lTest.Test(QFastSizeRange<decltype(b)>::value,"QFastSizeRange<vector>");
    lTest.Test(QFastSizeRange<decltype(g)>::value,"QFastSizeRange<list>");
    lTest.Test(QFastSizeRange<decltype(range(b))>::value,"QFastSizeRange<range(vector)>");
    lTest.Test(!QFastSizeRange<decltype(range(g))>::value,"QFastSizeRange<range(list)>");
    lTest.Test(QFastSizeRange<decltype(a)>::value,"QFastSizeRange<char*>");
    lTest.Test(QFastSizeRange<decltype(c)>::value,"QFastSizeRange<int[]>");
    lTest.Test(!QFastSizeRange<decltype(f)>::value,"QFastSizeRange<int[]>");

    return lTest.ReturnCode();
}
